<?php
/**
 * Description of StaticWacFormStatus
 *   WacStatus references 
 *
 * @author ben
 */
class StaticWacFormStatus
{
    public static $notsave    = "notsave";
    public static $init       = "init";
    public static $processing = "processing";
    public static $finish     = "finish";
    public static $audited    = "audited";

    public static $params = array(
          'notsave'        => array('id'=>"0", 'group'=>'1', 'name'=>"notsave", 'caption'=>"未保存"),
          'init'           => array('id'=>"1", 'group'=>'1', 'name'=>"init", 'caption'=>"初始"),
          'processing'     => array('id'=>"2", 'group'=>'1', 'name'=>"processing", 'caption'=>"进行中"),
          'audited'        => array('id'=>"3", 'group'=>'1', 'name'=>"audited", 'caption'=>"已审批"),
          'finish'         => array('id'=>"100", 'group'=>'1', 'name'=>"finish", 'caption'=>"已完结"),
    );

    public static function getInstance()
    {
        $class = __CLASS__;
        if(is_null(self::$_instance)) {
            self::$_instance = new $class();
        }
        return self::$_instance;
    }

    public function __construct()			// construct method
    {
        ;
    }

    /*
     * get attribute
     */
    public static function getAttribute($key, $attribute)
    {
        return self::$params[$key][$attribute];
    }

    /*
     * getId
     */
    public static function getId($key)
    {
        return self::getAttribute($key, 'id');
    }

    /*
     * getName
     */
    public static function getName($key)
    {
        return self::getAttribute($key, 'name');
    }

    /*
     * getCaption
     */
    public static function getCaption($key)
    {
        return self::getAttribute($key, 'caption');
    }

    /*
     * getCaption
     */
    public static function getCaptionById($id)
    {
        return self::getAttributeById($id, 'caption');
    }

    /*
     * @return caption
     */
    public static function getAttributeById($id, $attribute)
    {
        $row = self::getRowById($id);
        if($row != false){
            return $row[$attribute];
        }
    }

    /*
     *  getRowById
     * @return false or found array
     */
    public static function getRowById($id)
    {
        $result = false;
        foreach(self::$params as $param)
        {
            if($param['id']==$id)
            {
                $result = $param;
                break;
            }
        }
        return $result;
    }

}
